home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
tcsel003.zip
/
EXPFHT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-10-16
|
2KB
|
75 lines
unit expfht;
{ Author: Trevor J Carlsen Released into the public domain }
{ PO Box 568 }
{ Port Hedland }
{ Western Australia 6721 }
{ Voice +61 91 732 026 }
{ EXPFHT: This unit allows an application to expand the number of file }
{ handles in use. It is limited to the number permitted by DOS and }
{ initialised in the FILES= of the config.sys file. }
interface
const
NumbFiles= 105;
{ Set to the number of file handles needed. 99 will be the max with }
{ DOS 2.x and 254 with DOS 3.x. (I don't know why not 255!) }
type
fht = array[1..NumbFiles] of byte;
var
NewFHT : fht;
OldFHT : longint;
OldSize : word;
function MakeNewFHT: boolean;
procedure RestoreOldFHT;
implementation
const
Successful : boolean = false;
var
OldExitProc : pointer;
{$R-}
function MakeNewFHT : boolean;
{ create a new expanded file handle table - TRUE if successful }
const
AlreadyUsed : boolean = false;
begin
if not AlreadyUsed then begin
AlreadyUsed := true;
MakeNewFHT := true;
Successful := true;
OldFHT := MemL[PrefixSeg:$34]; { Store the old FHT address }
FillChar(NewFHT,NumbFiles,$ff); { Fill new table with 255 }
Oldsize := MemW[PrefixSeg:$32]; { Store the old FHT size }
MemW[PrefixSeg:$32] := NumbFiles; { Put new size in the psp }
MemL[PrefixSeg:$34] := longint(@NewFHT); { new FHT address in psp }
move(Mem[PrefixSeg:$19],NewFHT,$15); { put contents of old to new }
end { if not AllreadyUsed }
else MakeNewFHT := false;
end; { MakeNewFHT }
{$R+}
{$F+}
procedure RestoreOldFHT;
begin
ExitProc := OldExitProc;
if Successful then begin
MemW[PrefixSeg:$32] := OldSize;
MemL[PrefixSeg:$34] := OldFHT;
end;
end;
{$F-}
begin
OldExitProc := ExitProc;
ExitProc := @RestoreOldFHT;
end.